package top.yongyan0624.utils;

import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.HtmlEmail;
import org.springframework.stereotype.Component;

/**
 * @author Yongyan
 * @description: TODO
 * @date 2021/8/31
 **/
@Component
public class EmailUtils {
    public static void sendEmail(String recipient,String theme,String content) {
        try {
            HtmlEmail email=new HtmlEmail();
            email.setHostName("smtp.163.com");
            email.setCharset("utf-8");
            email.setFrom("fdsdzh2021@163.com","智慧小巷");
            email.setAuthentication("fdsdzh2021@163.com", "TMXYHTWPARBNNPDP");
            email.addTo(recipient);
            email.setSubject(theme);
            email.setMsg(content);
            email.send();

        } catch (EmailException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }
}
